From: Mikhail Kshevetskiy Date: Fri, 10 Jan 2025 08:23:54 +0000 (+0300) Subject: ptgen: fix misprint and simplify calculation a bit X-Git-Url: http://git.openwrt.org/%22https:/collectd.org///%22https:/collectd.org/?a=commitdiff_plain;h=996dc482a7e88985e25ccb8b6829cbd2ae3e1a53;p=project%2Ffirmware-utils.git ptgen: fix misprint and simplify calculation a bit 2 << ((10 * exp) - 1) is equal to 1 << (10 * exp). This allows us simplify a formula and remove extra if. Signed-off-by: Mikhail Kshevetskiy --- diff --git a/src/ptgen.c b/src/ptgen.c index c7d6bc0..e5fee0d 100644 --- a/src/ptgen.c +++ b/src/ptgen.c @@ -203,10 +203,8 @@ static long to_kbytes(const char *string) return 0; } - /* result: number + 1024^(exp) */ - if (exp == 0) - return result; - return result * (2 << ((10 * exp) - 1)); + /* result: number * 1024^(exp) */ + return result * (1 << (10 * exp)); } /* convert the sector number into a CHS value for the partition table */